﻿<UserControl x:Class="YouTubePlaylist.Views.TracksCtrl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" 
    xmlns:Ctrls="clr-namespace:Radovici.Ctrls;assembly=RadoviciCtrls" 
    xmlns:SharedLibrary="clr-namespace:Radovici.SharedLibrary;assembly=RadoviciSharedLibrary" 
    xmlns:Views="clr-namespace:YouTubePlaylist.Views" 
    xmlns:ContentControls="clr-namespace:Radovici.Ctrls.ContentControls;assembly=RadoviciCtrls" 
    xmlns:Hacks="clr-namespace:Radovici.Ctrls.Hacks;assembly=RadoviciCtrls">
    <UserControl.Resources>
        <SharedLibrary:BooleanToVisibilityConverter x:Key="ToVisibilityConverter"/>
    </UserControl.Resources>
    <ContentControls:DropTarget TargetDataContext="{Binding PlaylistModel}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Hacks:DataGridPlus x:Name="TracksGrid" Grid.Row="0" ItemsSource="{Binding PlaylistModel.Playlist.Tracks}" SelectedItem="{Binding PlaylistModel.Current}" Margin="0,2,0,2"
                                    IsReadOnly="True" AutoGenerateColumns="False" SelectionChanged="OnTrackSelectionChanged"
                                    MouseLeftButtonUp="OnMouseLeftButtonUp" MouseDoubleClicked="OnDoubleClicked" KeyUp="OnTracksKeyUp"
                                    Visibility="{Binding PlaylistModel.HasTracks, Converter={StaticResource ToVisibilityConverter}}">
                <Hacks:DataGridPlus.Columns>
                    <Data:DataGridTextColumn Header="Artist" Binding="{Binding Artist}"/>
                    <Data:DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
                    <Data:DataGridTextColumn Header="Type" Binding="{Binding Category}"/>
                    <Data:DataGridTemplateColumn Header="Video">
                        <Data:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <ContentControls:Dropable VerticalAlignment="Center">
                                    <TextBlock Text="{Binding SelectedUrl}"/>
                                </ContentControls:Dropable>
                            </DataTemplate>
                        </Data:DataGridTemplateColumn.CellTemplate>
                    </Data:DataGridTemplateColumn>
                </Hacks:DataGridPlus.Columns>
            </Hacks:DataGridPlus>
            <Views:TrackOptionsCtrl x:Name="TrackOptions" Grid.Row="1" Margin="0,2,0,2"/>
        </Grid>
    </ContentControls:DropTarget>
</UserControl>
